package cn.tedu.boot01.controller;

import cn.tedu.boot01.entity.Emp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class ParamController {
    @RequestMapping("/p1")
    @ResponseBody
    public String p1(HttpServletRequest request){
        String name = request.getParameter("name");
        String age = request.getParameter("age");
        return name+":"+age;
    }

    @RequestMapping("/p2")
    @ResponseBody
    public String p2(String name,int age){
        return name+"::"+age;
    }

    @RequestMapping("/p3")
    @ResponseBody //内部是通过SpringMVC框架 + 反射的方式获取传递过来的参数并赋值给了Emp对象
    public String p3(Emp emp){

        return emp.toString();
    }



}
